<?php
class gui{
	public $path;
	public $controller;
	public $url;

	public function __construct($controller){
		$this->controller = $controller;
		$this->path = $controller->path;
		$this->url = $controller->url;
	}

	public function show(){
		$page = "view/".$this->url[0]."/".$this->url[0].".php";
		if(!file_exists($page)){
			$this->controller->redirect("error/404/".implode("/", $this->url));
		}

		if(isset($_SESSION["user"]) && !empty($_SESSION["user"])) $u = $_SESSION["user"];

		$link = $this->path."index.php?url=";
		$self = $link.implode("/", $this->controller->url);
		$css = $this->path."public/css/";
		$img = $this->path."public/img/";
		$js = $this->path."public/js/";

		$show = false;
		if(!empty($this->controller->message)){
			$message = $this->controller->message;
			$show = true;
		}

		switch($this->url[0]){
			case "registration":
			case "error":
			case "login": require($this->url[0]."/".$this->url[0].".php"); break; 
			default: require("layout.php"); break;
		}

		$this->controller->database->close();
	}
}
?>